<template>
  <div class="bar-chart" ref="barChartRef">BarChart</div>
</template>

<script lang="ts">
export default {
  name: 'BarChart',
}
</script>

<script lang="ts" setup>
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'

const barChartRef = ref()
onMounted(() => {
  //初始化
  const myEchart = echarts.init(barChartRef.value)
  const option = {
    xAxis: {
      data: [
        '一月',
        '二月',
        '三月',
        '四月',
        '五月',
        '六月',
        '七月',
        '八月',
        '九月',
        '十月',
        '十一月',
        '十二月',
      ],
      show: false,
    },
    yAxis: {
      show: false,
    },
    series: {
      type: 'bar',
      data: [25, 20, 25, 12, 18, 11, 23, 15, 45, 45, 11, 22],
    },
    grid: {
      left: 0,
      right: 0,
      top: 10,
      bottom: 0,
    },
  }
  myEchart.setOption(option)
})
</script>

<style scoped>
.bar-chart {
  width: 100%;
  height: 100%;
}
</style>
